package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.NoticeCheck;

@Repository
public interface NoticeCheckDao extends JpaRepository<NoticeCheck, Integer>, JpaSpecificationExecutor<NoticeCheck> {

	@Query("from NoticeCheck where notice_id = ?1")
	List<NoticeCheck> find(String name);

	@Query("from NoticeCheck where notice_id like ?1")
	List<NoticeCheck> findLike(String name);

	@Query(value = "select * from NoticeCheck limit ?, ?", nativeQuery = true)
	List<NoticeCheck> findPage(Integer offset, Integer size);

	@Query(value = "select * from NoticeCheck where notice_id = ? limit ?, ?", nativeQuery = true)
	List<NoticeCheck> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from NoticeCheck where notice_id like ? limit ?, ?", nativeQuery = true)
	List<NoticeCheck> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from NoticeCheck where notice_id = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from NoticeCheck where notice_id like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from NoticeCheck order by id asc")
	List<NoticeCheck> findAllAsc();
}

